<?php
$this->breadcrumbs=array(
	'Items'=>array('index'),
	$model->name,
);

$this->menu=array(
	array('label'=>'List Item', 'url'=>array('index')),
	array('label'=>'Create Item', 'url'=>array('create')),
	array('label'=>'Update Item', 'url'=>array('update', 'id'=>$model->id)),
	array('label'=>'Delete Item', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->id),'confirm'=>'Are you sure you want to delete this item?')),
	array('label'=>'Manage Item', 'url'=>array('admin')),
);
?>

<h1>View Item #<?php echo $model->id; ?></h1>

<?php $this->widget('bootstrap.widgets.BootDetailView', array(
	'data'=>$model,
	'attributes'=>array(
		'id',
		'kind_id',
		'real_id',
		'name',
	),
)); ?>


<h2>Revisions</h2>


<div class="row-fluid">
<div class="span12">

<form action="" method="post" name="compare" id="form-revision">
<?php $this->widget('bootstrap.widgets.BootGridView',array(
	'type'=>'striped',
	'id'=>'children-entries-grid',
	'dataProvider'=>new CArrayDataProvider($model->revisions),
	'columns'=>array(
		'id',
		'comment',
		'created_by',
		'created_time',
		array(
			'header'=>'Revition 1',
			'type'=>'raw',
			'value'=>"CHtml::radioButton('revision-1', false, array(
						'value'=>".'$data->id'.",
						'id'=>'abc',
						'uncheckValue'=>null
					)); ",
			'htmlOptions'=>array(
				'style'=>'width:70px; text-align: center',
			),

		),
		array(
			'header'=>'Revition 2',
			'type'=>'raw',
			'value'=>"CHtml::radioButton('revision-2', false, array(
						'value'=>".'$data->id'.",
						'id'=>'abc',
						'uncheckValue'=>null
					)); ",
			'htmlOptions'=>array(
				'style'=>'width:70px; text-align: center',
			),
		),
		array(
			'header'=>'Compare Before',
			'type'=>'raw',
			'value'=>"CHtml::link('Before', array('log/compareBefore','id'=>".'$data->id'.",'item_id'=>4)); ",
			'htmlOptions'=>array(
				'style'=>'width:70px; text-align: center',
			),
		),
		array(
			'header'=>'Compare After',
			'type'=>'raw',
			'value'=>"CHtml::link('After', array('log/compareAfter','id'=>".'$data->id'.",'item_id'=>4)); ",
			'htmlOptions'=>array(
				'style'=>'width:70px; text-align: center',
			),
		),
	),
)); ?>

<input type="submit" class="btn btn-primary btn-small" name="submit" value="Compare">
</form>
</div>
</div>

<script language="JavaScript">
<!--
  $("form#form-revision").submit(function(){
	  var check_v1 = $("input[name='revision-1']:checked").length;
	  var check_v2 = $("input[name='revision-2']:checked").length;

	  if(check_v1==0 || check_v2==0){
		  alert('Bạn cần chọn đầy đủ 2 phiên bản cần so sánh');
		  return false;
	  }

	  var value_v1=$("input[name='revision-1']:checked").val();
	  var value_v2=$("input[name='revision-2']:checked").val();

	  if(value_v1==value_v2){
		  alert('Không thể so sánh cùng phiên bản');
		  return false;
	  }
	  return true;
  })
//-->
</script>